home *** CD-ROM | disk | FTP | other *** search
- /* C code generated by: */
- /* Visual Arts Version 2.5 */
- /* Copyright (c)1994-95 Danny Y. Wong All rights reserved */
- /* Calgary, Alberta (CANADA) */
-
- extern struct xword * FindNodeNo(struct List *, UWORD);
- extern void IndexAGuiDrawRects(struct Window *Wind);
- extern struct Window *IndexAGuiWnd;
- extern struct Gadget *IndexAGuiGadgets[IndexAGuiNumGads];
- extern void CreateIndexAGuiLists(void);
- extern void SortMinList (struct List *);
- extern UBYTE *linksLabels[];
- struct List *IndexAGuiLists[1];
-
- void IndexAGuiDrawRects(struct Window *Wind)
- {
- UWORD offsetx = Scr->WBorLeft;
- UWORD offsety = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
-
- SetDrPt(Wind->RPort, 0xFFFF);
- SetOPen(Wind->RPort, 0);
- SetAfPt(Wind->RPort, NULL, 0);
- }
-
- void CreateIndexAGuiLists(void)
- {
- short i;
-
- i=0;
- while (linksLabels[i])
- AddNewNode(IndexAGuiLists[0], linksLabels[i++]);
-
- }
-
- /* gadget functions */
-
- int butSaveObj(struct VAobject VAObject)
- {
- /* Save word list */
- char wordsfile[160];
- struct xword *new;
- BPTR file;
-
- strcpy(wordsfile,Wordpath);
- strcat(wordsfile,"/");
- strcat(wordsfile,WordFile);
-
- if(exwords)
- {
- if(!(file=Open(wordsfile, MODE_NEWFILE)))
- {
- char errorstr[80]="Can't open file ";
- strcat(errorstr, WordFile);
- strcat(errorstr, "for output!");
- error(errorstr);
- }
- else
- {
-
- for (new= (struct xword *)exwords->lh_Head; new->nextxword.ln_Succ; new=(struct xword *)new->nextxword.ln_Succ)
- {
- FPuts(file,new->nextxword.ln_Name); /* release size of word + the NULL */
- FPuts(file,"\n");
- }
- }
- Close(file);
- }
-
- if(!(file=Open("IndexAG.prefs", MODE_NEWFILE)))
- error("Can't open preference file for output!");
- else
- {
- char temp[5]="";
- FPuts(file,Wordpath);
- FPuts(file,"\n");
- FPuts(file,WordFile);
- FPuts(file,"\n");
- FPuts(file,groupstart);
- FPuts(file,"\n");
- FPuts(file,groupend);
- FPuts(file,"\n");
- sprintf(temp,"%d\n",threshold);
- FPuts(file,temp);
- sprintf(temp,"%d\n",nolinks);
- FPuts(file,temp);
- sprintf(temp,"%d\n",-(comment));
- FPuts(file,temp);
- Close(file);
- }
- return(1L);
- }
- /* Button Save */
-
- int butNewObj(struct VAobject VAObject)
- {
- newpress=TRUE;
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_strExword], IndexAGuiWnd, NULL, GA_Disabled, FALSE, TAG_END);
- ActivateGadget(IndexAGuiGadgets[ID_strExword], IndexAGuiWnd, NULL);
-
- return(1L);
- }
- /* Button New */
-
- int butCreateObj(struct VAobject VAObject)
- {
- makeindexfile();
- return(1L);
- }
- /* Button Create Index */
-
- int butDeleteObj(struct VAobject VAObject)
- {
- struct xword *DelNode;
- if (ListViewitem != ~0)
- {
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, ~0, TAG_END);
- DelNode = FindNodeNo(exwords, ListViewitem);
- FreeMem(DelNode->nextxword.ln_Name, strlen(DelNode->nextxword.ln_Name)+1);
- Remove((struct Node *)DelNode);
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, exwords, GTLV_Selected, ~0, TAG_END);
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_strExword], IndexAGuiWnd, NULL, GA_Disabled, TRUE, GTST_String, "", TAG_END);
- }
-
- return(1L);
- }
- /* Button Delete */
-
- int strFileObj(struct VAobject VAObject)
- {
- strcpy(GuideName,GetString(IndexAGuiGadgets[ID_strFile]));
- return(1L);
- }
- /* String File */
-
- int intThresObj(struct VAobject VAObject)
- {
- threshold = GetNumber(IndexAGuiGadgets[ID_intThres]);
- return(1L);
- }
- /* Integer Threshold */
-
- int strWordObj(struct VAobject VAObject)
- {
- strcpy(WordFile ,GetString(IndexAGuiGadgets[ID_strWord]));
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, ~0, TAG_END);
- readwords();
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, exwords, TAG_END);
-
- return(1L);
- }
- /* String Word File */
-
- int strStartObj(struct VAobject VAObject)
- {
- strcpy(groupstart,GetString(IndexAGuiGadgets[ID_strStart]));
- return(1L);
- }
- /* String Start */
-
- int strEndObj(struct VAobject VAObject)
- {
- strcpy(groupend,GetString(IndexAGuiGadgets[ID_strEnd]));
- return(1L);
- }
- /* String End */
-
- int strExwordObj(struct VAobject VAObject)
- {
- struct xword *oldword=NULL, *newword;
-
- char *temp=NULL;
- char tempstr[80]="";
- strcpy(tempstr,GetString(IndexAGuiGadgets[ID_strExword]));
- strip(tempstr," ", 'B');
- if (tempstr != "")
- {
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, ~0, TAG_END);
-
- if (newpress== TRUE)
- {
- if (exwords==NULL)
- {
- if(!(exwords=AllocMem(sizeof(struct List), MEMF_CLEAR)))
- error("Can't create new word list!");
- else
- NewList(exwords);
- }
-
- if (!(newword=AllocMem(sizeof(struct xword),MEMF_CLEAR))) /* Allocate space for the node */
- error("Not enough memory for newword structure\n");
- else
- {
- newword->nextxword.ln_Name = NULL;
- if (!(temp=AllocMem(strlen(buffer)+1, MEMF_CLEAR))) /* Allocate for the word */
- error("Not enough memory to store word\n");
- else
- {
- newword->nextxword.ln_Name = temp; /* point our word pointer to the memory allocated */
- strcpy(temp, tempstr);
- AddTail((struct List *)exwords, (struct Node *)newword); /* add it to the list */
- }
- }
- }
-
- else
- {
- if (!(temp = AllocMem(strlen(tempstr)+1, MEMF_CLEAR)))
- error("Can't allocate memory for word!");
- else
- {
- oldword = FindNodeNo(exwords, ListViewitem);
- FreeMem(oldword->nextxword.ln_Name, strlen(oldword->nextxword.ln_Name)+1);
-
- strcpy(temp,tempstr);
- oldword->nextxword.ln_Name = temp;
- }
- }
-
- SortMinList(exwords);
- }
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, exwords, GTLV_Selected, ~0, TAG_END);
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_strExword], IndexAGuiWnd, NULL, GA_Disabled, TRUE, GTST_String, "", TAG_END);
- newpress = FALSE;
-
-
- return(1L);
- }
- /* String */
-
- int chkCommentObj(struct VAobject VAObject)
- {
- comment = !comment;
-
- return(1L);
- }
-
- void toggleck(void)
- {
- comment = !comment;
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_chkComment],IndexAGuiWnd, NULL, GTCB_Checked, comment, TAG_END);
- }
-
- /* Check Box Comment */
-
- int mxLinksObj(struct VAobject VAObject)
- {
- int value = VAObject.va_IntuiMsg->Code;
- if (value == 0)
- {
- nolinks=1;
- nowords=0;
- }
- else
- {
- nolinks=0;
- nowords=1;
- }
-
-
- return(1L);
- }
-
- void togglemx(void)
- {
- nolinks=!nolinks;
- nowords=!nowords;
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_mxLinks],IndexAGuiWnd, NULL, GTMX_Active, !nolinks, TAG_END);
- }
-
- /* MX */
-
- int listExclude(struct VAobject VAObject)
- {
- ListViewitem = VAObject.va_IntuiMsg->Code;
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_strExword], IndexAGuiWnd, NULL, GA_Disabled, FALSE, TAG_END);
-
- return(1L);
- }
- /* ListView Exclude words */
-
- int butFileObj(struct VAobject VAObject)
- {
-
- struct TagItem frtags[] =
- {
- ASL_Hail, (ULONG)"Please Choose an AmigaGuide file",
- ASL_Height, 250,
- ASL_Width, 200,
- ASL_LeftEdge, 100,
- ASL_TopEdge, 100,
- ASL_OKText, (ULONG)"OK",
- ASL_CancelText, (ULONG)"Cancel",
- ASL_Pattern, (ULONG)"#?.Guide",
- ASL_Dir, (ULONG)Guidepath,
- ASL_FuncFlags, FILF_PATGAD,
- TAG_DONE
- };
-
- struct FileRequester *fr;
-
- if (AslBase = OpenLibrary("asl.library", 37L))
- {
- if (fr = (struct FileRequester *)AllocAslRequest(ASL_FileRequest, frtags))
- {
- if (AslRequest(fr,NULL))
- {
- strcpy(GuideName,fr->rf_File);
- strcpy(Guidepath,fr->rf_Dir);
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_strFile], IndexAGuiWnd, NULL, GTST_String, GuideName, TAG_END);
- }
- FreeAslRequest(fr);
- }
- CloseLibrary(AslBase);
- }
- return(1L);
- }
- /* Hilight butFileget */
-
- int butWords19Obj(struct VAobject VAObject)
- {
-
- struct TagItem frtags[] =
- {
- ASL_Hail, (ULONG)"Please choose a word file",
- ASL_Height, 250,
- ASL_Width, 200,
- ASL_LeftEdge, 100,
- ASL_TopEdge, 100,
- ASL_OKText, (ULONG)"OK",
- ASL_CancelText, (ULONG)"Cancel",
- ASL_Dir, (ULONG)Wordpath,
- TAG_DONE
- };
-
-
- struct FileRequester *fr;
-
- if (AslBase = OpenLibrary("asl.library", 37L))
- {
- if (fr = (struct FileRequester *)AllocAslRequest(ASL_FileRequest, frtags))
- {
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, ~0, TAG_END);
- if (AslRequest(fr,NULL))
- {
- strcpy(WordFile, fr->rf_File);
- strcpy(Wordpath, fr->rf_Dir);
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_strWord], IndexAGuiWnd, NULL, GTST_String, WordFile, TAG_END);
- }
- FreeAslRequest(fr);
- }
- CloseLibrary(AslBase);
- readwords();
- GT_SetGadgetAttrs(IndexAGuiGadgets[ID_listExclude],IndexAGuiWnd, NULL, GTLV_Labels, exwords, TAG_END);
- }
- return(1L);
- }
- /* Hilight butWordsget */
-
-